<?php

namespace common\behavior;

use Webman\Stomp\Client;

/**
 * 异步处理版本发布事件
 */
class VersionPublishedAsyncQueueBehavior
{
    public function run($params)
    {
        $data = $params['update_data'] ?? [];
        if (empty($data)
            || !array_key_exists('is_publish', $data)
            || $data['is_publish'] !== 'yes'
        ) {
            return;
        }
        Client::send('version_published', build_queue_data_with_xu(['id' => $params['primary_id']]), 3);
    }
}
